package org.haifi.game.compiler;

import java.net.URI;

import javax.tools.SimpleJavaFileObject;

/**
 * 内存java源码对象
 * 
 * @author joycube2
 * 
 */
class JavaSourceFromString extends SimpleJavaFileObject {
	final String code;

	/**
	 * name不要包含package,仅指定类名即可
	 * 
	 * @param name
	 * @param code
	 */
	JavaSourceFromString(String name, String code) {
		super(URI.create("string:///" + name + Kind.SOURCE.extension),
				Kind.SOURCE);
		this.code = code;
	}

	@Override
	public CharSequence getCharContent(boolean ignoreEncodingErrors) {
		return code;
	}
}